<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
$url="";
if(isset($_REQUEST['url'])){
    $url=$_REQUEST['url'];
}
?>

<form action="getimage.php" method="get">
    <input type="text" name="url" value="<?php echo $url?>" placeholder="Enter Image Url"/>
    <button type="submit"/>Decode</button>
</form>

<?php
if(isset($_REQUEST['url'])){
    $file=  file_get_contents($_REQUEST['url']);
    $image = imagecreatefromstring($file);
    // start buffering
    ob_start();
    imagepng($image);
    $contents =  ob_get_contents();
    ob_end_clean();
    echo "<table><tr><th>Input</th><th>Output</th></tr><tr><td><img src=\"".$_REQUEST['url']."\" /></td><td>";
    echo "<img src='data:image/png;base64,".base64_encode($contents)."' /></td></tr></table>";
    
    echo "<h1>Decoded String</h1><textarea style='width:800px;overflow:auto' onclick=\"this.select();\">";
    echo htmlentities("data:image/png;base64,".base64_encode($contents));
    echo '</textarea>';
    echo "<h2>Usage</h2><textarea style='width:800px;overflow:auto' onclick=\"this.select();\">";
    echo htmlentities("<img src='data:image/png;base64,".base64_encode($contents)."' />").'</textarea>';
    imagedestroy($image);
}
?>



